package com.mallcai.bigdata.ladon.dpl.mapper.common;

import com.mallcai.bigdata.ladon.dpl.entity.common.CommonInfo;
import com.mallcai.bigdata.ladon.dpl.mapper.common.provider.CommonInfoSqlProvider;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author gst
 * @date 2019-12-30 20:36
 */
@Repository
public interface CommonInfoMapper {

    @InsertProvider(type = CommonInfoSqlProvider.class, method = "insert")
    int insert(CommonInfo commonInfo);

    @UpdateProvider(type = CommonInfoSqlProvider.class, method = "update")
    int update(CommonInfo commonInfo);

    @UpdateProvider(type = CommonInfoSqlProvider.class, method = "delete")
    int delete(CommonInfo commonInfo);

    @SelectProvider(type = CommonInfoSqlProvider.class, method = "findById")
    CommonInfo findById(@Param("id") Long id);

    @SelectProvider(type = CommonInfoSqlProvider.class, method = "getByParams")
    List<CommonInfo> getByParams(@Param("params") Map<String, Object> params);

    @Select({
            "SELECT * FROM " + CommonInfoSqlProvider.TB_COMMON_INFO + " WHERE archive = 0  AND classify = #{classify}"
    })
    List<CommonInfo> getByClassify(@Param("classify") String classify);

    @SelectProvider(type = CommonInfoSqlProvider.class, method = "hasExist")
    int hasExist(@Param("classify") String classify, @Param("code") String code, @Param("name") String name, @Param("filterId") Long filterId);
}
